package com.itheima.filter;

import jakarta.servlet.*;
import jakarta.servlet.annotation.WebFilter;
import lombok.extern.slf4j.Slf4j;
import java.io.IOException;

@Slf4j
//@WebFilter(urlPatterns = "/depts/*")
@WebFilter(urlPatterns = "/*")
//@WebFilter(urlPatterns = "/login")
public class DemoFilter implements Filter {

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        System.out.println("");
        log.info("DempFilter init .........");
       // Filter.super.init(filterConfig);
    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain chain) throws IOException, ServletException {
        System.out.println("拦截器");
        log.info("拦截到了请求，doFilter........");
        //放行
        chain.doFilter(servletRequest,servletResponse);

    }

    @Override
    public void destroy() {
        log.info("DemoFilter destroy.........");
       // Filter.super.destroy();
    }
}
